package com.example.student.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.constants.RdsConstants;
import com.example.common.domain.pojo.Ppt;
import com.example.common.utils.CacheClient;
import com.example.student.mapper.PPTMapper;
import com.example.student.service.PPTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class PPTServiceImpl extends ServiceImpl<PPTMapper, Ppt> implements PPTService {

    @Autowired
    private PPTMapper pptMapper;
    @Autowired
    private CacheClient cacheClient;

//    @Override
//    public Handouts getHandoutsById(String HandoutsId){
//        return handoutsMapper.selectById(HandoutsId);
//    }

    @Override
    public Ppt getPPTById(String templateIndexId) {
        // 使用逻辑过期策略获取ppt信息
        return cacheClient.queryWithLogicalExpire(
                RdsConstants.PPT_INFO,
                templateIndexId,
                Ppt.class,
                this::getById, // 使用MyBatis-Plus的基础方法
                RdsConstants.CACHE_NULL_TTL,
                TimeUnit.MINUTES,
                false
        );
    }


}
